<?php
 
class PhpFox_Mod_Video_ComponentRelated extends BaseComponent
{
    function process()
    {
    	App::checkUserAccess('video', array('full', 'read_only'));
    
		$sSearch = $this->getParam('search');
		$iVidId = $this->getParam('vidid');
		
		if ( !$sSearch )
		{
			return;
		}
		
		$iPageTotal = (App::getParam('vid_related_total') ? App::getParam('vid_related_total') : 8);		

		$aItems = $this->oDatabase->getRows("
			SELECT 
				v.vid_id, v.vid_title 
			FROM ". App::getT('videos') ." AS v
				JOIN " . App::getT('user') . " AS u ON(v.vid_userid = u.id)
			WHERE v.vid_id != '" . $iVidId . "' AND v.vid_title LIKE '%". $this->oDatabase->escape($sSearch) ."%'
			ORDER BY v.vid_time DESC LIMIT 0,". $iPageTotal . "
			");

		$this->oTpl->assign(array
		(
			'sGImageUrl' => App::getParam('video.image.url'),
			'aItems' => $aItems,
		));

    	return $this->oTpl->fetch('Related.html');
    }
}

?>